var http = require('http');
var url = require('url');
var fs = require('fs');

http.createServer(function (request,response) {


     var urlObj = url.parse(request.url,true);
     console.log(urlObj);

     /**
      *   如何在模板页面加载jquery之类的外部文件
      * */
     if (urlObj.pathname=='/'){
         fs.readFile('template/login.html',function (err,data) {
             response.end(data.toString());
         })
     }
     
     if (urlObj.pathname=='/login') {

         /**
            做一些判断
            if 用户名和密码都正确，跳转index.html
         */
         fs.readFile('template/index.html',function (err,data) {
             response.end(data.toString());
         })

     }

}).listen(3000);


console.log("the server is running on port 3000");